//
//  SEGCompleteInfoView.m
//  ExcellentHome
//
//  Created by 梁昆 on 2017/11/9.
//  Copyright © 2017年 陈区. All rights reserved.
//

#import "SEGCompleteInfoView.h"
//#import "UIButton+WebCache.h"

@implementation SEGCompleteInfoView
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    [self addSubview:self.completeInfoLabel];
    [self addSubview:self.promptLabel];
    [self addSubview:self.progressBarView];
    [self addSubview:self.selectGenderImage2];
    [self addSubview:self.littleCircle2];
    [self addSubview:self.selectGenderImage];
    [self addSubview:self.genderLabel];
    [self addSubview:self.personalInfoLabel];
    [self addSubview:self.JobLabel];
    [self addSubview:self.updateImage];
    [self addSubview:self.updateLabel];
    [self addSubview:self.line];
    [self addSubview:self.line2];
    [self addSubview:self.nickNameLabel];
    [self addSubview:self.inputNickeName];
    

    [self.completeInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).mas_offset(85);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.promptLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.completeInfoLabel.mas_bottom).mas_offset(10);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.progressBarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.promptLabel.mas_bottom).mas_offset(40);
        make.centerX.equalTo(self.mas_centerX);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(1.5);
    }];
    
    [self.selectGenderImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.progressBarView);
        make.width.height.mas_equalTo(10);
    }];
    
    [self.littleCircle2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.progressBarView.mas_right);
        make.centerY.equalTo(self.progressBarView.mas_centerY);;
    }];
    
    [self.selectGenderImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.progressBarView.mas_left).mas_offset(-2);
        make.centerY.equalTo(self.progressBarView.mas_centerY);
        make.width.height.mas_equalTo(10);
    }];
    
    [self.genderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.progressBarView.mas_bottom).mas_offset(10);
        make.centerX.equalTo(self.selectGenderImage.mas_centerX);
    }];
    
    [self.personalInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.progressBarView.mas_bottom).mas_offset(10);
        make.centerX.equalTo(self.selectGenderImage2.mas_centerX);
    }];
    
    [self.JobLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.progressBarView.mas_bottom).mas_offset(10);
        make.centerX.equalTo(self.littleCircle2.mas_centerX);
    }];
    
    [self.updateImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.personalInfoLabel.mas_bottom).mas_offset(80);
        make.centerX.equalTo(self.mas_centerX);
        make.width.height.mas_equalTo(66);
    }];
    
    [self.updateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.updateImage.mas_bottom).mas_offset(10);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.updateLabel.mas_bottom).mas_offset(40);
        make.left.right.mas_equalTo(self);
        make.height.mas_equalTo(0.5 * kScaleHeight);
    }];
    
    [self.line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line.mas_bottom).mas_offset(44);
        make.left.right.mas_equalTo(self);
        make.height.mas_equalTo(0.5 * kScaleHeight);
    }];
    
    [self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line.mas_bottom).mas_offset(15);
        make.left.equalTo(self.mas_left).mas_offset(15);
    }];
    
    [self.inputNickeName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line.mas_bottom).mas_offset(15);
        make.left.equalTo(self.nickNameLabel.mas_right).mas_offset(15);
        make.right.equalTo(self.mas_right).mas_offset(-15);
        make.width.mas_equalTo(200);
    }];
    
}

#pragma mark - 代理功能方法
-(void)updateImageBtnToClick{
    [self.delegate updateImageBtnClick];
}

#pragma mark - getter
// 完善资料获得积分
-(UILabel *)completeInfoLabel{
    if (!_completeInfoLabel) {
        _completeInfoLabel = [[UILabel alloc] init];
//        _completeInfoLabel.text = @"完善资料可获得800积分";
        _completeInfoLabel.font = [UIFont systemFontOfSize:18];
        _completeInfoLabel.textColor = kColor_T;
    }
    return _completeInfoLabel;
}

// 让大家更懂你
-(UILabel *)promptLabel{
    if (!_promptLabel) {
        _promptLabel = [[UILabel alloc] init];
        _promptLabel.text = @"让大家更懂你";
        _promptLabel.font = [UIFont systemFontOfSize:15];
        _promptLabel.textColor = kColor_T;
    }
    return _promptLabel;
}

// 完善资料进度条
-(UIView *)progressBarView{
    if (!_progressBarView) {
        _progressBarView = [[UIView alloc] init];
        _progressBarView.backgroundColor = kColor_L2;
        _progressBarView.layer.cornerRadius = 0.75;
        _progressBarView.layer.masksToBounds = YES;
    }
    return _progressBarView;
}

// 选中按钮2
-(UIImageView *)selectGenderImage2{
    if (!_selectGenderImage2) {
        _selectGenderImage2 = [[UIImageView alloc] init];
        _selectGenderImage2.image = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select")];
    }
    return _selectGenderImage2;
}

// 小圆圈
-(UIImageView *)littleCircle2{
    if (!_littleCircle2) {
        _littleCircle2 = [[UIImageView alloc] init];
        _littleCircle2.image = [UIImage imageWithContentsOfFile:SEGPicName(@"img_dot")];
    }
    return _littleCircle2;
}

// 选择性别图标
-(UIImageView *)selectGenderImage{
    if (!_selectGenderImage) {
        UIImage *image = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select")];
        _selectGenderImage = [[UIImageView alloc] initWithImage:image];
    }
    return _selectGenderImage;
}

// 性别
-(UILabel *)genderLabel{
    if (!_genderLabel) {
        _genderLabel = [[UILabel alloc] init];
        _genderLabel.text = @"性别";
        _genderLabel.font = [UIFont systemFontOfSize:11];
        _genderLabel.textColor = kColor_T;
    }
    return _genderLabel;
}

// 个人资料
-(UILabel *)personalInfoLabel{
    if (!_personalInfoLabel) {
        _personalInfoLabel = [[UILabel alloc] init];
        _personalInfoLabel.text = @"个人资料";
        _personalInfoLabel.font = [UIFont systemFontOfSize:11];
        _personalInfoLabel.textColor = kColor_T;
    }
    return _personalInfoLabel;
}

// 职业
-(UILabel *)JobLabel{
    if (!_JobLabel) {
        _JobLabel = [[UILabel alloc] init];
        _JobLabel.text = @"职业";
        _JobLabel.font = [UIFont systemFontOfSize:11];
        _JobLabel.textColor = kColor_3;
    }
    return _JobLabel;
}

//上传头像按钮
-(UIButton *)updateImage{
    if (!_updateImage) {
        _updateImage = [[UIButton alloc] init];
        NSString* imagePath = [SEGProfileManager sharedManager].profile.ico;
        
        [_updateImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kClientImageRootURL,imagePath]] forState:UIControlStateNormal placeholderImage:[UIImage imageWithContentsOfFile:SEGPicName(@"icon_logon_upload")]];

        _updateImage.layer.cornerRadius = 33.0f;
        _updateImage.layer.masksToBounds = YES;
        _updateImage.backgroundColor = [UIColor clearColor];
        [_updateImage addTarget:self action:@selector(updateImageBtnToClick) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _updateImage;
}

//上传头像文本
-(UILabel *)updateLabel{
    if (!_updateLabel) {
        _updateLabel = [[UILabel alloc] init];
        _updateLabel.text = @"上传头像";
        _updateLabel.textColor = kColor_3;
        _updateLabel.font = [UIFont systemFontOfSize:13];
    }
    return _updateLabel;
}

-(UIView *)line{
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = kColor_L2;
    }
    return _line;
}

-(UIView *)line2{
    if (!_line2) {
        _line2 = [[UIView alloc] init];
        _line2.backgroundColor = kColor_L2;
    }
    return _line2;
}

-(UILabel *)nickNameLabel{
    if (!_nickNameLabel) {
        _nickNameLabel = [[UILabel alloc] init];
        _nickNameLabel.text = @"昵称";
        _nickNameLabel.textColor = kColor_1;
        _nickNameLabel.font = [UIFont systemFontOfSize:16];
    }
    return _nickNameLabel;
}

-(UITextField *)inputNickeName{
    if (!_inputNickeName) {
        _inputNickeName = [[UITextField alloc] init];
        _nickNameLabel.font = [UIFont systemFontOfSize:16];
        _inputNickeName.textColor = kColor_1;
        _inputNickeName.tintColor = kColor_T;
        _inputNickeName.textAlignment = NSTextAlignmentRight;
        _inputNickeName.returnKeyType = UIReturnKeyDone;
        _inputNickeName.clearsOnBeginEditing = NO;
        _inputNickeName.clearButtonMode = UITextFieldViewModeWhileEditing;
    }
    return _inputNickeName;
}

@end
